function MySort(arr) {
  const rec = (arr) => {
    if (arr.length <= 1) return arr;
    let left = [];
    let right = [];
    let n = arr[0];
    for (let i = 1; i < arr.length; i++) {
      if (arr[i] > n) {
        right.push(arr[i]);
      } else {
        left.push(arr[i]);
      }
    }
    return [...rec(left), n, ...rec(right)];
  }
  return rec(arr);
}

console.log(MySort([3, 5, 1, 4, 6]))
